<template>
  <div id="app" :class="RefreshShow ? 'smart-page' : flagPath ? 'flagPath' : ''">
    <keep-alive>
      <router-view v-if="keepAlive"></router-view>
    </keep-alive>
    <router-view  v-if="!keepAlive"></router-view>
    <NavTabBar v-if="$route.meta.navShow" />
  </div>
</template>

<script>
import { Icon, Sticky } from 'vant'

import NavTabBar from './douyin/NavBar'

export default {
  name: 'App',
  data () {
    return {
      RefreshShow: false,
      pathList: [
        '/home'
      ]
    }
  },
  components: {
    [Icon.name]: Icon,
    [Sticky.name]: Sticky,
    NavTabBar
  },
  watch: {
    '$route' (route) {
      if (route.path === '/home') {
        const title = this.$t('router.home')
        this.$setTitle(title)
      } else {
        this.$setTitle(route.name)
      }
    }
  },
  computed: {
    // query 里面带参 keepAlive 等于1 的情况也做为缓存处理
    keepAlive () {
      if (this.$route.meta.keepAlive || Number(this.$route.query.keepAlive) === 1) {
        return true
      }
      return false
    },
    flagPath () {
      if (this.pathList.includes(this.$route.path)) {
        return true
      } else {
        return false
      }
    }
  },
  methods: {
  },
  beforeCreate () {},
  async mounted () {
    const env = await this.$getEnv()
    this.$store.commit('updateB2cEnv', env)
  }
}
</script>

<style lang="less">
html,body{
  height: 100%;
  background-color: #F0F0F0;
  -webkit-text-size-adjust: 100% ;
}
body { padding-bottom: env(safe-area-inset-bottom); }
#app {
  max-width: 460px;
  margin: auto;
  >div {
    max-width: 460px;
  }
  .z-pop {
    padding-bottom: 10px;
  }
  .arrow-down-p {
    padding-top: 10px;
  }
  .close-app {
    background-color: transparent;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    height: 60px;
    margin-bottom: 10px;
    .van-icon {
      padding-top: 5px;
      padding-left: 10px;
    }
  }
}
.flagPath {
  padding-bottom: 50px;
}
.smart-page {
  .member-user-box {
    padding-top: 45px;
  }
  .appointList, .appointProduct, .appointInfo, .my-voucher, .live, .particulars, .searchSmartCity {
    padding-top: 40px;
  }
  .place-order {
    padding-top: 35px;
  }
  .z-search-nav-bar {
    height: 79px;
    .z-search-box.restore {
      padding-top: 30px;
      height: 77px;
    }
    .van-nav-bar {
      display: flex;
      flex-direction: row;
      align-items: flex-end;
      height: 79px;
    }
  }
  .z-detail-swipe-box {
    margin-top: 40px;
  }
  > div {
    &:nth-of-type(2) {
      .van-sticky--fixed {
        top: 79px !important;
      }
    }
    &:nth-of-type(3) {
      .van-sticky--fixed {
        top: 125px !important;
      }
    }
  }
}
.el_hide {
  display: none !important;
}
</style>
